package com.gjintel.framework.projecttype.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.gjintel.framework.projecttype.dao.IProjectTypeDao;
import com.gjintel.framework.projecttype.model.ProjectType;
import com.gjintel.sdk.base.dao.HibernateGenericDAO;
import com.gjintel.sdk.base.dao.Page;
import com.gjintel.sdk.base.dao.Sort;
import com.gjintel.sdk.util.StringUtil;
/**
 * @description 项目类别数据处理实现
 * @author cxj
 */
@Repository("projectTypeDao")
public class ProjectTypeDaoImpl extends HibernateGenericDAO implements IProjectTypeDao{
	@SuppressWarnings("unchecked")
	public List<ProjectType> findAll() {
		String hql = "from ProjectType g ";
		return this.find(hql);
	}

	@SuppressWarnings("unchecked")
	public void findAll(Page page, ProjectType projectType) {
		StringBuffer hql = new StringBuffer("from ProjectType g ");
		List<Object> params = new ArrayList<Object>();
		if (projectType != null) {
			if (!StringUtil.isEmpty(projectType.getName())) {
				hql.append(" and g.name like ? ");
				params.add("%" + projectType.getName().trim() + "%");
			}
		}
		this.findAsPage(hql.toString(), page, null, "g", false, params.toArray());
	}
	
	

	
}
